package com.dd.admin.business.sellPay.controller;

import cn.hutool.core.bean.BeanUtil;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.dd.admin.common.model.UpdateGroup;
import com.dd.admin.common.model.result.ResultBean;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import javax.validation.constraints.NotBlank;
import com.dd.admin.business.sellPay.entity.Sellpay;
import com.dd.admin.business.sellPay.domain.SellpayVo;
import com.dd.admin.business.sellPay.domain.SellpayDto;
import com.dd.admin.business.sellPay.service.SellpayService;

import java.util.List;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 订单支付 前端控制器
 * </p>
 *
 * @author 727869402@qq.com
 * @since 2024-06-19
 */
@Api(tags = "订单支付")
@RestController
public class SellpayController {

    @Autowired
    SellpayService sellPayService;

    @ApiOperation(value = "订单支付-分页列表")
    @ApiOperationSupport(order = 1)
    @GetMapping("/admin/sellPay/page")
    public ResultBean<IPage<SellpayVo>> page(SellpayDto sellPayDto) {
        IPage<SellpayVo> pageInfo = sellPayService.selectSellpayPage(sellPayDto);
        return ResultBean.success(pageInfo);
    }

    @ApiOperation(value = "订单支付-列表")
    @ApiOperationSupport(order = 2)
    @GetMapping("/admin/sellPay/list")
    public ResultBean<List<SellpayVo>> list(SellpayDto sellPayDto) {
        List<SellpayVo> list = sellPayService.selectSellpayList(sellPayDto);
        return ResultBean.success(list);
    }

    @ApiOperation(value = "订单支付-添加")
    @ApiOperationSupport(order = 3)
    @PostMapping("/admin/sellPay/add")
    public ResultBean<Sellpay> add(@RequestBody @Validated SellpayDto sellPayDto) {
        Sellpay sellPay = BeanUtil.copyProperties(sellPayDto, Sellpay.class);
        sellPayService.save(sellPay);
        return ResultBean.success(sellPay);
    }

    @ApiOperation(value = "订单支付-查询")
    @ApiOperationSupport(order = 4)
    @GetMapping("/admin/sellPay/{sellPayId}")
    public ResultBean<SellpayVo> get(@PathVariable @NotBlank String sellPayId) {
        Sellpay sellPay = sellPayService.getById(sellPayId);
        SellpayVo sellPayVo = BeanUtil.copyProperties(sellPay,SellpayVo.class);
        return ResultBean.success(sellPayVo);
    }

    @ApiOperation(value = "订单支付-修改")
    @ApiOperationSupport(order = 5)
    @PostMapping("/admin/sellPay/update")
    public ResultBean<Sellpay> update(@RequestBody @Validated(UpdateGroup.class) SellpayDto sellPayDto) {
        Sellpay sellPay = BeanUtil.copyProperties(sellPayDto, Sellpay.class);
        sellPayService.updateById(sellPay);
        return ResultBean.success(sellPay);
    }

    @ApiOperation(value = "订单支付-删除")
    @ApiOperationSupport(order = 6)
    @GetMapping("/admin/sellPay/delete/{sellPayId}")
    public ResultBean<Sellpay> delete(@PathVariable @NotBlank String sellPayId) {
        Boolean b = sellPayService.removeById(sellPayId);
        return ResultBean.success(b);
    }
}
